<?php

/**
 * question actions.
 *
 * @package    iEasy
 * @subpackage question
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class questionActions extends sfActions
{
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {
        //        $this->forward('default', 'module');
    }


    public function executePost(sfWebRequest $request)
    {
        $content = $request->getParameter('content');
        $userId = $request->getParameter('userId');
        $qcId = $request->getParameter('qcId');
        $src = $request->getParameter("src");
        $ip = utility::getRequestIp($request);
        $question = new Question();
        $question->setCreateTime(date(Constants::$DEFAULT_DATETIME_FORMAT));
        $question->setUserId($userId);
        $question->setQuestionChannelId($qcId);
        $question->setContent($content);
        $question->setIp($ip);
        $question->save();
        if ($request->isXmlHttpRequest()) {

            if ($src == "questionList")
                return $this->renderComponent('question', 'questionList', array("qcId" => $qcId));
            else
                return $this->renderComponent('question', 'entry');
        }
    }
}
